import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';

import { Directive, ElementRef } from '@angular/core';
import {addTrenchPage} from './addTrench/addTrench';

//  http
import {Http,Headers} from '@angular/http';

import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/timeout';

@Component({
  selector: 'page-contact',
  templateUrl: 'contact.html'
})
export class ContactPage {

    dealerInfo={};
    items=[];

    constructor(public navCtrl: NavController,private el:ElementRef,public http:Http) {

    }


 //添加经销商账户
    addTrench() {
            this.navCtrl.push(addTrenchPage);
        }
    ngAfterViewInit(){
        this.http.get('../assets/data/infoData.json')
            .toPromise()
            .then((response) => {
                // this.infoData = response.json().infoData;
                this.dealerInfo = response.json().infoData;
                console.info(this.dealerInfo);
            })
            .catch( err => {
                console.log('err');
            });
        //input输入框中的数据
        this.http.get('../assets/data/list.json')
            .toPromise()
            .then((response) => {
                console.info(response.json().infoData.items)
                this.items = response.json().infoData.items;
                console.info(this.items[0].productName)
            })
            .catch( err => {
                console.log('err');
            })


        }

}
